package com.dk.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dk.data.Result;
import com.dk.data.ResultEnum;
import com.dk.pojo.content.TbContent;
import com.dk.service.content.ContentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("content")
public class ContentController {

    private final Logger logger = LoggerFactory.getLogger(ContentController.class);

    @Reference
    private ContentService contentService;

    @RequestMapping("listContentByCategoryId")
    @ResponseBody
    public Result listContentByCategoryId(Long categoryId) {
        try {
            List<TbContent> contents = contentService.listContentByCategoryId(categoryId);
            return Result.response(ResultEnum.OK).setData(contents);
        } catch (Exception e) {
            return Result.response(ResultEnum.FAIL);
        }
    }
}
